{extend name="public:base" /}
{block name="title"}{$site_title}{/block}
{block name="content"}
<!--/sidebar-->
<div class="main-wrap">
    <div class="crumb-wrap">
        <div class="crumb-list">
            <i class="icon-font"></i>
            <a href="/baibu/admin/Index">首页</a>
            <span class="crumb-step">&gt;</span>
            <a class="crumb-name" href="/baibu/admin/Link/">友情链接</a>
            <span class="crumb-step">&gt;</span>
            <span>{$nav}</span>
        </div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <form action="{$url}" method="post" id="myform" name="myform" enctype="multipart/form-data">
                <table class="insert-tab" width="100%">
                    <tbody>
                    <tr>
                        <th width="120">
                            <i class="require-red">*</i>链接名称：
                        </th>
                        <td>
                            <input class="common-text required" name="link_name" size="50" value="{$info.link_name|default=''}" type="text">
                        </td>
                    </tr>
                    <tr>
                        <th width="120">
                            <i class="require-red">*</i>链接地址：
                        </th>
                        <td>
                            <input class="common-text required" name="link_url" size="50" value="{$info.link_url|default=''}" type="text">
                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input id="sub" class="btn btn-primary btn6 mr10" value="提交" type="button">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
<!--/main-->
{/block}
{block name="js"}
<script>
    $(function () {
        $('#sub').click(function(){
            if($('input[name=link_name]').val() == ''){
                layer.msg('链接名称不能为空', {icon: 5,time:1200});
                return;
            }
            if($('select[name=link_url]').val() == ''){
                layer.msg('链接地址不能为空', {icon: 5,time:1200});
                return;
            }
            var url = $('form').attr('action');
            $.ajax({
                url : url,
                dataType : "json",
                type : "post",
                data : $('form').serialize(),
                success :function (data) {
                    if(data.status){
                        layer.msg(data.msg,{icon:1,time:1200,end:function () {
                                location.href=data.data;
                            }});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1200});
                    }
                }
            });
        });
    });
</script>
{/block}